package me.sdevil507.platform.mapper;

import me.sdevil507.platform.dto.PlatResourceModuleResultDto;
import me.sdevil507.platform.dto.PlatResourceParamsDto;
import me.sdevil507.platform.dto.PlatResourceResultDto;
import me.sdevil507.platform.dto.PlatResourceSimpleResultDto;
import me.sdevil507.platform.po.PlatResourcePo;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 资源Mapper[PlatResourceMapper]
 *
 * @author sdevil507
 * created on 2020-06-23 18:43:30
 */
@Component
@Mapper(componentModel = "spring")
public interface PlatResourceMapper {

    /**
     * po => dto
     *
     * @param po 实体类
     * @return dto传输类
     */
    PlatResourceResultDto po2dto(PlatResourcePo po);

    /**
     * po => simpleDto
     *
     * @param po 实体类
     * @return dto传输类
     */
    PlatResourceSimpleResultDto po2SimpleDto(PlatResourcePo po);

    /**
     * po => moduleDto
     *
     * @param po po
     * @return modulesDto
     */
    PlatResourceModuleResultDto po2ModulesDto(PlatResourcePo po);

    /**
     * pos => dtos
     *
     * @param pos 实体类集合
     * @return dtos传输类集合
     */
    List<PlatResourceResultDto> pos2dtos(List<PlatResourcePo> pos);

    /**
     * pos => simpleDtos
     *
     * @param pos pos
     * @return dtos
     */
    List<PlatResourceSimpleResultDto> pos2SimpleDtos(List<PlatResourcePo> pos);

    /**
     * pos => moduleDtos
     *
     * @param pos pos
     * @return moduleDtos
     */
    List<PlatResourceModuleResultDto> pos2ModuleDtos(List<PlatResourcePo> pos);

    /**
     * dto => po
     *
     * @param dto 传输类
     * @return po实体类
     */
    PlatResourcePo dto2po(PlatResourceParamsDto dto);

    /**
     * dtos => pos
     *
     * @param dtos 传输类集合
     * @return pos实体类集合
     */
    List<PlatResourcePo> dtos2pos(List<PlatResourceParamsDto> dtos);

    /**
     * 使用dto更新po
     *
     * @param dto 传输类
     * @param po  实体类
     */
    void updatePoFromDto(PlatResourceParamsDto dto, @MappingTarget PlatResourcePo po);
}